﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DDD;
using Xunit;

namespace DokiDokiTest {
    public class TestKeyframeSequece {
        [Fact]
        public void Test_New1 () {
            var kseq = (KeyframeSequence)new KeyframeSequence<int> (4, 1);

            Assert.Equal (InterpolationType.Linear, kseq.InterpolationType);
            Assert.Equal (KeyframeRepeatMode.Once, kseq.RepeatMode);
            Assert.Equal (typeof (int), kseq.ValueType);
            Assert.Equal (1, kseq.ComponentCount);
            Assert.Equal (0, kseq.Duration);
            Assert.Equal (4, kseq.KeyframeCount);
            Assert.Equal (0, kseq.ValidRangeStart);
            Assert.Equal (0, kseq.ValidRangeEnd);
            Assert.Equal (false, kseq.ShouldBeNormalized);
        }

        [Fact]
        public void Test_SetDuration () {
            var kseq = (KeyframeSequence)new KeyframeSequence<int> (4, 1);
            
            kseq.SetDuration (100);

            Assert.Equal (100, kseq.Duration);
        }

        [Fact]
        public void Test_SetValidRange () {
            var kseq = (KeyframeSequence)new KeyframeSequence<int> (4, 1);

            kseq.SetValidRange (100, 200);

            Assert.Equal (100, kseq.ValidRangeStart);
            Assert.Equal (200, kseq.ValidRangeEnd);
        }

        [Fact]
        public void Test_SetRepeatMode () {
            var kseq = (KeyframeSequence)new KeyframeSequence<int> (4, 1);

            kseq.SetRepeatMode (KeyframeRepeatMode.Loop);

            Assert.Equal (KeyframeRepeatMode.Loop, kseq.RepeatMode);
        }

        [Fact]
        public void Test_SetInterpolationType () {
            var kseq = (KeyframeSequence)new KeyframeSequence<int> (4, 1);

            kseq.SetInterpolationMode (InterpolationType.Step);

            Assert.Equal (InterpolationType.Step, kseq.InterpolationType);
        }

        [Fact]
        public void Test_Similar () {
            var kseq1 = (KeyframeSequence)new KeyframeSequence<int> (4, 1);
            var kseq2 = (KeyframeSequence)new KeyframeSequence<int> (4, 1);
            var kseq3 = (KeyframeSequence)new KeyframeSequence<int> (4, 2);
            var kseq4 = (KeyframeSequence)new KeyframeSequence<int> (3, 1);
            var kseq5 = (KeyframeSequence)new KeyframeSequence<float> (4, 1);

            Assert.Equal (true, kseq1.Similar(kseq2));
            Assert.Equal (false, kseq1.Similar (kseq3));
            Assert.Equal (false, kseq1.Similar (kseq4));
            Assert.Equal (false, kseq1.Similar (kseq5));
        }
    }
}
